package oralExamSchedulingSystemTest;

import entity.Class;
import entity.Group;
import entity.Room;
import entity.Student;
import entity.TimeSlot;
import graph.Graph;
import graph.Vertex;

import java.util.ArrayList;

import junit.framework.Assert;
import oralExamSchedulingSystem.SubjectTimeTable;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TestSubjectTimeTable {

	private SubjectTimeTable subjectTimeTable;
	private Graph studentRecordGraph = new Graph();
	private String year="2013";
	private String semester="B";
	private String subjectName;
	private String reportingRoom;
	private ArrayList<String> roomsUsedByThisSubject;
	private String date;
	private String startTime;
	private String level;

	private int durationPerGroup;
	private int numberOfStudentPerGroup;

	/** The Graph g */
	private Graph studentRecordTestGraph = new Graph();
	private Graph subjectTimeTableTestGraph = new Graph();

	private Vertex vertexC1 = new Vertex(Class.class, new Class("5A"));
	private Vertex vertexC2 = new Vertex(Class.class, new Class("5B"));
	private Vertex vertexC3 = new Vertex(Class.class, new Class("5C"));

	private Vertex vertexS1 = new Vertex(Student.class, new Student(1, 1, "Ivana", 'F'));
	private Vertex vertexS2 = new Vertex(Student.class, new Student(2, 2, "Steve", 'F'));
	private Vertex vertexS3 = new Vertex(Student.class, new Student(3, 3, "Steven", 'M'));
	private Vertex vertexS4 = new Vertex(Student.class, new Student(4, 1, "Ivana", 'F'));
	private Vertex vertexS5 = new Vertex(Student.class, new Student(5, 2, "Eddie", 'F'));
	private Vertex vertexS6 = new Vertex(Student.class, new Student(6, 3, "Chris", 'M'));


	private Vertex vertexG1 = new Vertex(Group.class, new Group(1));
	private Vertex vertexG2 = new Vertex(Group.class, new Group(2));
	private Vertex vertexG3 = new Vertex(Group.class, new Group(3));
	

	private Vertex vertexR1 = new Vertex(Room.class, new Room("501"));
	private Vertex vertexR2 = new Vertex(Room.class, new Room("502"));
	

	Vertex vertexT1 = new Vertex(TimeSlot.class, new TimeSlot("9:00", 15));
	Vertex vertexT2 = new Vertex(TimeSlot.class, new TimeSlot("9:15", 15));

	@Before
	public void setUp() throws Exception {

		studentRecordGraph.addVertex(vertexC1);
		studentRecordGraph.addVertex(vertexC2);
		studentRecordGraph.addVertex(vertexC3);
		
		studentRecordGraph.addVertex(vertexS1);
		studentRecordGraph.addVertex(vertexS2);
		studentRecordGraph.addVertex(vertexS3);
		studentRecordGraph.addVertex(vertexS4);
		studentRecordGraph.addVertex(vertexS5);
		studentRecordGraph.addVertex(vertexS6);

		studentRecordGraph.addEdge(vertexS1, vertexC1, 0);
		studentRecordGraph.addEdge(vertexS2, vertexC1, 0);
		studentRecordGraph.addEdge(vertexS3, vertexC1, 0);
		
		studentRecordGraph.addEdge(vertexS4, vertexC2, 0);
		studentRecordGraph.addEdge(vertexS5, vertexC2, 0);
		studentRecordGraph.addEdge(vertexS6, vertexC2, 0);
		
		
		studentRecordTestGraph = studentRecordGraph.shadowCopy();
		subjectTimeTableTestGraph = studentRecordGraph.shadowCopy();
		
		
		subjectTimeTableTestGraph.addVertex(vertexT1);
		subjectTimeTableTestGraph.addVertex(vertexT2);
		
	
		subjectTimeTableTestGraph.addVertex(vertexR1);
		subjectTimeTableTestGraph.addVertex(vertexR2);

		subjectTimeTableTestGraph.addVertex(vertexG1);
		subjectTimeTableTestGraph.addVertex(vertexG2);
		subjectTimeTableTestGraph.addVertex(vertexG3);
		

		subjectTimeTableTestGraph.addEdge(vertexT1, vertexG1, 0);
		subjectTimeTableTestGraph.addEdge(vertexR1, vertexG1, 0);
	
		subjectTimeTableTestGraph.addEdge(vertexT1, vertexG2, 0);
		subjectTimeTableTestGraph.addEdge(vertexR2, vertexG2, 0);

		
		subjectTimeTableTestGraph.addEdge(vertexT2, vertexG3, 0);
		subjectTimeTableTestGraph.addEdge(vertexR1, vertexG3, 0);

		subjectName = "English";
		reportingRoom = "500";
		roomsUsedByThisSubject = new ArrayList<String>();
		roomsUsedByThisSubject.add("501");
		roomsUsedByThisSubject.add("502");
		date = "18-03-2013";
		startTime = "9:00";
		durationPerGroup = 15;
		numberOfStudentPerGroup = 2;
		year="2013";
		semester="B";
		level="1";
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSubjectTimeTableConstructor() {

		subjectTimeTable = new SubjectTimeTable(studentRecordGraph, subjectName,
				reportingRoom, roomsUsedByThisSubject, date, startTime,
				durationPerGroup, numberOfStudentPerGroup,year,semester,level);
		
		
		
		System.out.println("testSubjectTimeTableConstructor");


		System.out.println("subjectTimeTableTestGraph :\t" + subjectTimeTableTestGraph.toString());

		System.out.println("subjectTimeTable.getGraph() :\t" + subjectTimeTable.getGraph().toString());

		
		
		Assert.assertEquals(true, subjectTimeTableTestGraph.toString().equals(subjectTimeTable.getGraph().toString()));
		

	}

}
